﻿<%@ Page Title="" Language="C#" MasterPageFile="../Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SailHero.Soft.FrameWork.Models.SYS_SOFTWARE>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    新增软件
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server">
    <script src="<%=Page.ResolveUrl("../../Scripts/jquery.ajaxfileupload.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("../../Scripts/jquery.timers-1.2.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("../../Scripts/jquery.ui.core.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("../../Scripts/jquery-ui.min.js")%>" type="text/javascript"></script>
    <link href="<%=Page.ResolveUrl("../../Content/css/jquery-ui.css")%>" rel="stylesheet" type="text/css" />

    <script type="text/javascript">


        var p = 1;
        $(function () {
            $("#cancel").click(function () {
                window.location = "/Soft/index";
                //Test();
            });
            $("#submitBtn").click(function () {
                check();
                return false;
            });
            $('#dialog').dialog({
                autoOpen: false,
                width: 300,
                height: 100,
                modal: true,
                bgiframe: true
            });
            $('#dialog').dialog('close');
        });


        function Test() {
            $('#dialog').dialog('open');
            $("#progressbar").everyTime('1ds', function () {
                $(this).progressbar({ value: p });
                p = p + 1;
                if (p == 100) {
                    p = 1;
                }
            });
        }


        function check() {
            var SoftCName = $("#SoftCName").val();
            if (SoftCName == "") {
                $.messager.alert("提示信息", "软件名称不能为空", "info");
                return false;
            }
            var SoftNo = $("#SoftNo").val();
            if (SoftNo == "") {
                $.messager.alert("提示信息", "软件标识编号不能为空", "info");
                return false;
            }

            var fileToUpload = $("#fileToUpload").val();
            if (fileToUpload != "") {
                ajaxFileUpload();
            }
            else {
                $("#form1").submit();
            }

            return true;
        }

        function ajaxFileUpload() {
            $("#loading")
                .ajaxStart(function () {
                    $(this).show();
                    Test();
                })
                .ajaxComplete(function () {
                    $(this).hide();
                });
            $.ajaxFileUpload({
                url: '/Soft/Upload',
                secureuri: false,
                fileElementId: 'fileToUpload',
                dataType: 'json',
                success: function (data) {
                    ShowData(data);
                },
                error: function (data) {
                    ShowData(data);
                }
            });
        }

        function ShowData(data) {
            $("#progressbar").stopTime();
            $("#dialog").dialog("close");
            if (data.status == "error") {
                $("#status").html("上传失败：" + data.msg);
                $("#DownloadPath").val("");
            }
            else {
                $("#status").html("上传成功");
                $("#DownloadPath").val(data.msg);
                $("#form1").submit();
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="TabTitle" runat="server">
    新增软件
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <style>
        .ui-dialog-titlebar
        {
            display: none;
        }
    </style>
    <div id="dialog">
        <div id="progressbar" style=" margin-top:25px;">
        </div>
        请稍后，正在上传软件…
    </div>
    <div id="main_zone">
        <table width="99%" style="text-align: left;" border="0" align="center" cellpadding="3"
            cellspacing="1">
            <tr>
                <td width="18%" class="left_title_1">
                    软件名称
                </td>
                <td width="32%">
                    <%= Html.TextBoxFor(mod => mod.SOFTCNAME)%>
                </td>
                <td width="18%" class="left_title_1">
                    软件标识编号
                </td>
                <td width="32%">
                    <%= Html.TextBoxFor(mod => mod.SOFTNO)%>
                </td>
            </tr>
            <tr>
                <td class="left_title_2">
                    负责人电话
                </td>
                <td>
                    <%=Html.TextBoxFor(mod=>mod.TELEPHONE) %>
                </td>
                <td class="left_title_2">
                    负责人
                </td>
                <td>
                    <%=Html.TextBoxFor(mod=>mod.SOFTMANAGER) %>
                </td>
            </tr>
            <tr>
                <td class="left_title_1">
                    父类别
                </td>
                <td>
                    <%=Html.DropDownList("softList","请选择")%>
                </td>
                <td class="left_title_1">
                    排序号
                </td>
                <td>
                    <%=Html.TextBoxFor(mod=>mod.ORDERNUM) %>
                </td>
            </tr>
            <tr>
                <td class="left_title_2">
                    是否可用
                </td>
                <td>
                    <input id="isEnable" name="isEnable" checked="checked" type="checkbox" />
                </td>
                <td class="left_title_2">
                    程序文件(<100M)
                </td>
                <td>
                    <input id="fileToUpload" type="file" name="fileToUpload" style="width: 200px; height: 25px;" />&nbsp;&nbsp;&nbsp;<span
                        id="status" style="color: Red;"></span>
                    <img id="loading" src="<%=Page.ResolveUrl("../../Content/images/loading.gif")%>" style="display: none; height: 25px;
                        width: 25px;" />
                    <%=Html.HiddenFor(mod=>mod.DOWNLOADPATH) %>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="left_title_1" style="text-align: center;">
                    <input id="submitBtn" type="submit" value="保存" />
                    <input id="cancel" type="button" value="取消" />
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
